package com.twu.biblioteca.view.console.ui_element;

import com.google.common.collect.Maps;
import com.google.inject.Inject;

import com.twu.biblioteca.enums.ConsoleEvent;
import com.twu.biblioteca.view.command.Command;
import com.twu.biblioteca.view.command.CommandMap;

import java.util.Map;

public class MenuMap {
  private CommandMap commandMap;
  private Map<ConsoleEvent, Menu> menuMap;

  @Inject
  public MenuMap(CommandMap commandMap) {
    this.commandMap = commandMap;
    setMenus();
  }

  private void setMenus() {
    menuMap = Maps.newHashMap();

    Menu loginMenu = new HiddenMenu();
    loginMenu.add(new MenuItem("", this.commandMap.get(Command.Type.Login)));
    menuMap.put(ConsoleEvent.Login, loginMenu);

    Menu mainMenu = new MainMenu();
    mainMenu.add(new MenuItem("List Books", this.commandMap.get(Command.Type.BookList)));
    mainMenu.add(new MenuItem("Checkout Book", this.commandMap.get(Command.Type.CheckOutBook)));
    mainMenu.add(new MenuItem("Return Book", this.commandMap.get(Command.Type.ReturnBook)));
    mainMenu.add(new MenuItem("List Movies", this.commandMap.get(Command.Type.MovieList)));
    mainMenu.add(new MenuItem("Checkout Movie", this.commandMap.get(Command.Type.CheckOutMovie)));
    mainMenu.add(new MenuItem("Return Movie", this.commandMap.get(Command.Type.ReturnMovie)));
    mainMenu.add(new MenuItem("User Information", this.commandMap.get(Command.Type.UserInfo)));
    mainMenu.add(new MenuItem("Quit", this.commandMap.get(Command.Type.Quit)));
    menuMap.put(ConsoleEvent.MainMenu, mainMenu);
  }

  public Menu getMenu(ConsoleEvent event) {
    return menuMap.get(event);
  }
}

